package com.csun.cmny.provider.job.simple;

import com.csun.cmny.provider.service.OmcRpcService;
import com.csun.cmny.provider.service.OpcRpcService;
import com.csun.cmny.util.DateUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.paascloud.elastic.lite.annotation.ElasticJobConfig;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-10-29 14:25
 * @Description:
 *
 * 2019-11-17 00:00:00
 * 2019-11-18 00:00:00
 * 2019-11-19 00:00:00
 * 2019-11-20 00:00:00
 * 2019-11-21 00:00:00
 *
 */
@Slf4j
@ElasticJobConfig(cron = "0 0 0 * * ?")
//@ElasticJobConfig(cron = "0 0/1 * * * ?")
public class BatchCreateBillJob implements SimpleJob {

    @Resource
    private OmcRpcService omcRpcService;

    @Override
    public void execute(ShardingContext shardingContext) {

        // Date date = new Date();
        // Date date = DateUtil.strToDate("2019-11-16 00:00:00");
        // String date = "2019-11-16 00:00:00";
        // TODO 获取是的时间有可能会多一秒 2019-11-28 00:00:01
        String date = DateUtil.getDateStr(new Date()) + " 00:00:00";
        log.info("定时生成账单 ==》 {}", date);

        omcRpcService.batchCreateBill(date);
    }
}
